package cn.zuo.utils;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
 * @Author 白白旧维
 * @Date 2021/7/7 11:13
 */
public class MD5 {
    private static String salt = "doge666";//盐值

    public static String md5(String m){
        m = m+salt;
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        byte[] md5Bytes = md5.digest(m.getBytes());
        return binary(md5Bytes,16);
    }


    private static String binary(byte[] bytes, int radix){
        return new BigInteger(1, bytes).toString(radix);// 这里的1代表正数
    }

}
